<template>
  <div class="profile">
    <div class="return-bar" @click="back()">
        <i class="iconfont">&#xe668;</i>
        个人信息
    </div>

    <div class="detail_top">
        <group>
            <cell title="头像" style="padding: 25px 15px;"    >
                <span style="position: absolute;right: 25px;top: 50%;transform: translateY(-50%);">
                    <img :src="vData.avatar"  class="protrait" />
                </span>
            </cell>
        </group>

        <group>
            <cell title="实名认证"  is-link   @click=" setSetting(1) " >
                <span v-bind:class="{ 'not':vData.auth_realname == false }"> {{ vData.auth_realname || '未认证'}} </span>
            </cell>
            <cell title="手机认证" is-link    @click=" setSetting(2) " >
                <span v-bind:class="{ 'not':vData.auth_phone == false }"> {{ vData.auth_phone || '未认证'}} </span>
            </cell>

            <cell title="银行存管" is-link    @click=" setSetting(3) " >
                <span v-bind:class="{ 'not':vData.auth_bank == false }"> {{  vData.auth_bank ? '已开通' :'未开通'}}  </span>
            </cell>
            <cell title="绑卡激活"  is-link   @click=" setSetting(4) " >
                <span v-bind:class=" { 'not':vData.auth_bind == false } "> {{  vData.auth_bind ? '已绑卡' :'未绑卡'}}   </span>
            </cell>

            <cell title="风险测评" is-link    @click=" setSetting(5) " >
                <span v-bind:class=" { 'not':vData.risk == false } "> {{ vData.risk ? vData.risk :'未评估'}} </span>
            </cell>


            <cell title="银行卡管理"  is-link   >
                <span @click="showNotice" v-bind:class=" { 'not':vData.bankSet_status == false } "> {{  vData.bankSet_status ? vData.bankSet_account :'查看说明'}}   </span>

                <span  @click=" setSetting(6) " v-bind:class=" { 'not':vData.bankSet_status == false } "> {{  vData.bankSet_status ? '修改' :'添加'}}   </span>
            </cell>

        </group>
        <div style="text-align:right;padding: 0px 10px;margin-top:20px">
            <a v-link="{ path: '/user/delete' }" class="greybox">删除本帐号</a>
        </div>

    </div>

    <alert :show.sync=" alertMsg.show "  class="alert_com"  title="提示"  button-text="确定" >{{{alertMsg.msg}}}</alert>
    <dialog :show.sync="dialogData.show"   class="dialog_com"  >
        {{{dialogData.msg}}}
        <span class="vux-close" @click=" dialogData.show = false"></span>
    </dialog>
  </div>
</template>
<script>
import {Dialog, Alert, Group, Cell, Flexbox, FlexboxItem} from 'vux';
import {Api_Bind_Card} from '../../config/api'
import api from '../../data/api';
import { mapGetters } from 'vuex'
///recharge?type=34

export default {

    data(){
        return {
            dialogData: {
                show:false,
                msg:''
            },
            profile:require('../../assets/images/user/protrait.jpg'),
            busy:false,
            vData: {
                identified: true,
                cellphone: false,
                banked: false,
                binding: false,
                survey: false
            },
			alertMsg: {
				msg:'',
				show:false
            }
        }
    },

    computed: {
      ...mapGetters([
		  'loginStatus',
          'userInfo',
          'userProfile'
      ])
	},

    components:{
        Alert,
        Group,
        Cell,
        Flexbox,
        FlexboxItem,
        Dialog
    },

    methods: {
        setSetting(key){
            switch (key) {
                case 1:
                //if(this.vData.auth_realname == false){
                    //this.$route.router.go('/openAccount');

                    var strVar = "<div class='showGuide' >";
                    strVar += "<div class='title'>实名验证指引</div><div class='content'> "
                    strVar += "<p>根据中国人民银行《关于改进个人银行账户服务加强账户管理的通知》的要求，为强化银行账户管理、防范资金风险，电子账户必须完成实名认证才能提现。认证方式：</p>";
                    strVar += "<p>1. 下载华兴银行&#8220;投融资平台&#8221;APP；</p>";
                    strVar += "<p>2. APP左上角（图标&#8220;&#8801;&#8221;）-个人中心-实名认证；</p>";
                    strVar += "<p>3. 进行人脸扫描、身份证正反面照、手持身份证照上传。认证时间：</p>";
                    strVar += "<p>1. 工作日17:00前提出认证申请的，当天完成；17：00后的，T+1完成（节假日顺延）；</p>";
                    strVar += "<p>2. 非工作日T+1完成（节假日顺延）。</p>";
                    //strVar += '<div class="qrcodeCon"><h3>投融资平台APP下载二维码</h3><div class="qrcode"><img src="/themes/blue/img/users/ghbank_qrcode.png"/></div></div>'
                    strVar += '<div class="qrcodeCon"><h3>投融资平台APP下载二维码</h3><div class="qrcode"><img src="'+require('../../assets/images/user/ghbank_qrcode.png')+'"></div></div>'
                    strVar += "</div>"

					this.dialogData.msg = strVar;
                    this.dialogData.show = true;

               // }
                break;

                case 2:
                //if(this.vData.auth_phone == false)
                this.$route.router.go('/user/editphone');
                break;

                case 3:
                if(this.vData.auth_bank == false) this.$route.router.go('/openAccount');
                break;

                case 4:
                if(this.vData.auth_bind == false) this.$route.router.go('/recharge?type=card');
                break;

                case 5:
                //if(this.vData.risk == false)
                this.$route.router.go('/survey');
                break;

                case 6:
                this.$route.router.go('/user/add-bank-account');
                break;


            }
        },

		back(){
			this.$route.router.go('/user')
        },

        showNotice(){
            this.alertMsg.msg = '因华兴银行发奖励单笔只可发放200元，为了奖励正常发放，请添加本人名下实体银行卡，当有奖励时，有喜财富平台财务进行线下转账';
            this.alertMsg.show = true;
        }
    },

    route:{
        activate(transition){
            transition.next();

            var vm = this;
            api.user.profile().then( res => {
                if(res.status){
                    vm.vData = res;
                    vm.$store.dispatch('setUserProfile', res);
                    //console.log(vm.userProfile);

                    if(!vm.vData.avatar)
                        vm.vData.avatar = require('../../assets/images/user/protrait.jpg');
                }else{
					vm.alertMsg.msg = res.msg
                    vm.alertMsg.show = true;
                    setTimeout(function() {
                        vm.$route.router.go('/login?from=user/profile')
                    }, 1500);
                }
            })
        }
    }
}
</script>

<style lang="scss" scoped>



.profile{
    .detail_top {

        /* overflow-y: -webkit-paged-y; */
         padding-bottom: 10px;
    }

    .weui_cell{
        padding: 15px 15px;
        &:before{
            left:0;
        }
    }
    .protrait{
        width: 50px;
        border-radius: 50%;
    }
    .not{
        color:#ff7572;
    }

    .greybox{
    font-size: 15px;
    border: 1px solid #999;
    padding: 5px 10px;
    color: #999;
    border-radius: 4px;
    }
}


</style>

<style lang="scss" >

.alert_com{
    .weui_dialog {
        background:#fff;
    }
}

.dialog_com{
    .weui_dialog {
        background:none;
    }

    .showGuide{
        color: #333;
        font-size: 14px;
        text-align:left;
        .title{
            line-height: 40px;
            height:40px;
            border-top-left-radius:5px;
            border-top-right-radius:5px;
            font-size:18px;
            font-weight:bold;
            text-align:center;
            //margin-bottom:10px;
            background-color:#253238;
            color:#fff;
        }
        p{
            line-height:24px;
            margin-bottom:8px;
        }
        .content{
            height: 360px;
            overflow-y:scroll;
            padding: 10px;
            background-color: #fff;
            border-bottom-left-radius:5px;
            border-bottom-right-radius:5px;
        }

        .qrcodeCon{
            h3{
                background-color: #aa282f;
                margin:auto;
                text-align: center;
                color:#fff;
                height: 30px;
                line-height: 30px;
                border-radius: 5px;
                font-size: 13px;
                position: relative;
                margin-bottom:10px;
                &:after{
                    content:' ';
                    position: absolute;
                    border-width: 10px 10px 0;
                    border-left-color: transparent;
                    border-right-color: transparent;
                    border-top-color: #aa282f;
                    border-style: solid;
                    bottom:-12px;
                    left:50%;
                    z-index: 99;
                    transform: translate(-50%, -50%);
                }
            }
            .qrcode{
                width: 50%;
                margin:auto;
                img{
                    width: 100%;
                }
            }
        }
    }

}
.profile{
    .weui_cell_primary{
        min-width: 90px;
    }
}
</style>

<style lang="less">
@import '~vux/src/styles/close.less';

.vux-close{

    height: 28px;
    width: 28px;
    padding:20px;
    display: block;
    margin:auto;
    margin-top:20px;
    &:before, &:after{
        background-color: #fff;
    }
}
</style>
